package com.ruoyi.framework.shiro.web.filter;

import com.ruoyi.common.constant.ShiroConstants;
import org.apache.shiro.web.filter.AccessControlFilter;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

public class ApiFilter extends AccessControlFilter {

    @Override
    protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue){

        HttpServletRequest httpServletRequest = (HttpServletRequest) request;
        String key = httpServletRequest.getParameter("key");
        System.out.println(key);
        if("juneshen8888".equals(key)){
            System.out.println("allow in");
            return true;
        }else {
            return false;
        }



    }

    @Override
    protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception
    {

        request.setAttribute(ShiroConstants.CURRENT_CAPTCHA, ShiroConstants.CAPTCHA_ERROR);
        return false;
    }
}
